<ui:composition template="/templates/template.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui">

    <ui:define name="content">
        <h:form id="form">  
            <p:contextMenu for="myDatatable">  
                <p:menuitem value="View"  icon="ui-icon-search" update=":form:display  :form:orjinalShowedObject" oncomplete="PF('dataViewDialog').show()"/>  
                <p:menuitem value="Delete" icon="ui-icon-close" update="myDatatable" actionListener="#{lazyTableBean.deleteDataObject()}" />
            </p:contextMenu>  

            <p:dataTable id="myDatatable" widgetVar="datatable" lazy="true" liveResize="true" var="row" value="#{lazyTableBean.lazymodel}" draggableColumns="true" paginator="true" rows="15"
                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                         rowsPerPageTemplate="5,10,15"
                         rowKey="#{row.uniqueID}"
                         selection="#{lazyTableBean.selectedDataObject}"
                         selectionMode="single">  

                <p:ajax event="rowSelect" listener="#{lazyTableBean.onRowSelect}" update=":form:display" oncomplete="PF('dataViewDialog').show()"/>  
                <p:columns  value="#{lazyTableBean.lazymodel.columns}" var="column" columnIndexVar="colIndex">
                    <f:facet name="header">  
                        #{column.header} #{row.uniqueID}
                    </f:facet>  
                    #{row.multimap.get(column.header)}
                </p:columns>
            </p:dataTable>  


            <p:dialog dynamic="true" maximizable="true" minimizable="true"  closeOnEscape="true" header="Selected Row" widgetVar="dataViewDialog" resizable="false"  id="dialog">  

                <h:panelGrid id="display">  
                    <p:inputTextarea autoResize="false"  cols="20" rows="20" id="orjinalShowedObject" value="#{lazyTableBean.selectedDataObject.orjinalObject}"></p:inputTextarea>
                    <!--
                    <c:forEach items="#{tableBean.selectedDataObject.multimap}" var="selectedObject">
                        <h:inputText value="#{selectedObject.key}" />
                        <h:inputText value="#{selectedObject.value}" />
                    </c:forEach> 
                    -->
                    <f:facet name="footer">
                        <p:commandButton update="myDatatable" id="saveButton" value="Save2" actionListener="#{tableBean.insertObject()}" />         
                        <p:commandButton id="validateButton" value="Validate"/>    
                    </f:facet>
                </h:panelGrid>  
            </p:dialog>  
        </h:form>            
    </ui:define>
</ui:composition>